/*******************************************************************************
* Copyright (c) 2010, 2018 西安秦晔信息科技有限公司
* Licensed under the Apache License, Version 2.0 (the "License");
*    you may not use this file except in compliance with the License.
*    You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*    Unless required by applicable law or agreed to in writing, software
*    distributed under the License is distributed on an "AS IS" BASIS,
*    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*    See the License for the specific language governing permissions and
*    limitations under the License.
*******************************************************************************/
package com.qinyeit.serviceapp.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.qinyeit.serviceapp.entity.enums.DiscountType;
import com.qinyeit.serviceapp.entity.enums.State;
import com.qinyeit.serviceapp.entity.enums.UseScene;
import lombok.Builder;
import lombok.experimental.Tolerate;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

/**
 * ClassName: DiscountPlan <br/>
 * Function: 折扣方案 <br/>
 * date: 2018-11-29 09:56:09 <br/>
 *
 * @author liuwenjin
 * @version  1.0
 * @since JDK 1.8
 */
@Builder
@Entity
@Table(name="discount_plans")
public class DiscountPlan extends MerchantGroupBaseEntity<Long> {

	private static final long serialVersionUID = 1L;

	// 折扣类型 
    @Column(name="type", length = 300)
	@Enumerated(EnumType.STRING)
	private DiscountType type = DiscountType.AllSINGLE;

	// 折扣名称 
    @Column(name="name", length = 300)
	private String name = null;

//	// 是否为会员折扣
//    @Column(name="has_vip")
//	private Boolean hasVip = true;

//	// 适用场景
    @Column(name="use_scene")
	@Enumerated(EnumType.STRING)
	private UseScene useScene = UseScene.CARDTYPE;

	// 菜品库 (方案折扣的時候选择菜品库)
    @Column(name="store_id")
	private Long storeId = null;

	// 开始时间 
	@JSONField(format="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @Column(name="start_time")
	private Date startTime = null;

	// 结束时间 
	@JSONField(format="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @Column(name="end_time")
	private Date endTime = null;

	// 折扣率 
    @Column(name="discount",scale=2)
	private Double discount = null;
	// 特价折扣率
    @Column(name="special_discount",scale=2)
	private Double specialDiscount = null;

	// 操作人 
    @Column(name="operator_name", length = 300)
	private String operatorName = null;

	// 操作日期 
	@JSONField(format="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @Column(name="operate_time")
	private Date operateTime = null;

	// 状态 
    @Column(name="state", length = 300)
	@Enumerated(EnumType.STRING)
	private State state = State.NORMAL;

	//创建的时候生成 编辑的时候不变
	@Column(name="uuid", length = 300)
	private String uuid = "";

	//更新的时间戳 long
	@Column(name="update_timestamp")
	private Long updateTimestamp = null;

	@Transient
	private String branchs= "";


	public UseScene getUseScene() {
		return useScene;
	}

	public void setUseScene(UseScene useScene) {
		this.useScene = useScene;
	}

	@Tolerate
	public DiscountPlan() {
		
	}
    @Tolerate
	public DiscountPlan(Long id){
    	super.setId(id);
    }

	public String getBranchs() {
		return branchs;
	}

	public void setBranchs(String branchs) {
		this.branchs = branchs;
	}

	/**
	 * 获取折扣名称
	 */
	public String getName() {
		return this.name;
	}

    /**
     * 设置折扣名称
     */
	public DiscountPlan setName(String name) {
		this.name = name;
		return this;
	}


	/**
	 * 获取菜品库
	 */
	public Long getStoreId() {
		return this.storeId;
	}

    /**
     * 设置菜品库
     */
	public DiscountPlan setStoreId(Long storeId) {
		this.storeId = storeId;
		return this;
	}

	/**
	 * 获取开始时间
	 */
	public Date getStartTime() {
		return this.startTime;
	}

    /**
     * 设置开始时间
     */
	public DiscountPlan setStartTime(Date startTime) {
		this.startTime = startTime;
		return this;
	}

	/**
	 * 获取结束时间
	 */
	public Date getEndTime() {
		return this.endTime;
	}

    /**
     * 设置结束时间
     */
	public DiscountPlan setEndTime(Date endTime) {
		this.endTime = endTime;
		return this;
	}

	/**
	 * 获取折扣率
	 */
	public Double getDiscount() {
		return this.discount;
	}

    /**
     * 设置折扣率
     */
	public DiscountPlan setDiscount(Double discount) {
		this.discount = discount;
		return this;
	}

	/**
	 * 获取操作人
	 */
	public String getOperatorName() {
		return this.operatorName;
	}

    /**
     * 设置操作人
     */
	public DiscountPlan setOperatorName(String operatorName) {
		this.operatorName = operatorName;
		return this;
	}

	/**
	 * 获取操作日期
	 */
	public Date getOperateTime() {
		return this.operateTime;
	}

    /**
     * 设置操作日期
     */
	public DiscountPlan setOperateTime(Date operateTime) {
		this.operateTime = operateTime;
		return this;
	}

	public DiscountType getType() {
		return type;
	}

	public void setType(DiscountType type) {
		this.type = type;
	}

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public Long getUpdateTimestamp() {
		return updateTimestamp;
	}

	public void setUpdateTimestamp(Long updateTimestamp) {
		this.updateTimestamp = updateTimestamp;
	}

	public Double getSpecialDiscount() {
		return specialDiscount;
	}

	public void setSpecialDiscount(Double specialDiscount) {
		this.specialDiscount = specialDiscount;
	}
}
